//
//  LYChatViewController+CellEnums.swift
//  WeChat
//
//  Created by mac on 2018/9/5.
//  Copyright © 2018年 RRC. All rights reserved.
//

import Foundation
import UIKit

// MARK: - @extension 消息内容 cell 的扩展
extension MessageContentType {
    func chatCellHeight(_ model: ChatModel) -> CGFloat {
        switch self {
        case .Text:
            return LYChatTextCell.layoutHeight(model)
        
        case .Image:
            return LYChatImageCell.layoutHeight(model)
        
        case .Voice:
            return LYChatVoiceCell.layoutHeight(model)
            
        case .System:
            return LYChatSystemCell.layoutHeight(model)
            
        case .File:
            return 60
            
        case .Time:
            return LYChatTimeCell.heightForCell()
 
        }
    }
    
    func chatCell(_ tableView:UITableView, indexPath:IndexPath, model:ChatModel, viewController:LYChatViewController) -> UITableViewCell? {
        switch self {
        case .Text:
            let cell:LYChatTextCell = tableView.ts_dequeueReusableCell(LYChatTextCell.self)
            cell.setCellContent(model)
            return cell
            
        case .Image:
            let cell:LYChatImageCell = tableView.ts_dequeueReusableCell(LYChatImageCell.self)
            cell.setCellContent(model)
            return cell
            
        case .Voice:
            let cell:LYChatVoiceCell = tableView.ts_dequeueReusableCell(LYChatVoiceCell.self)
            cell.setCellContent(model)
            return cell
            
        case .System:
            let cell:LYChatSystemCell = tableView.ts_dequeueReusableCell(LYChatSystemCell.self)
            cell.setCellContent(model)
            return cell
            
        case .File:
            let cell:LYChatVoiceCell = tableView.ts_dequeueReusableCell(LYChatVoiceCell.self)
            cell.setCellContent(model)
            return cell
        
        case .Time :
            let cell: LYChatTimeCell = tableView.ts_dequeueReusableCell(LYChatTimeCell.self)
            cell.setCellContent(model)
            return cell
        }
    }
    
}

